<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>芯佑电商_产品列表</title>
    <#include "/website/commonWebsite.html">
    <!-- 分页插件 -->
    <script src="/website/js/jqPaginator.min.js" type="text/javascript"></script>
    <link href="/website/css/j-pagination.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!--==头部==-->
<div class="header">
    <#include "/website/header.html">
</div>
<!--==内容区域==-->
<div class="home_n">
    <div  class="home_nr">
        <!--==筛选==-->
        <div class="prolis-screen">
            <#if firstProductTypeList?? && firstProductTypeList?size &gt;0>
                <#list firstProductTypeList as item>
                    <div class="prolis-screen-list">
                        <h1>${item.product_type_name}</h1>
                        <input type="hidden" id="firstProductTypePk" value="${item.pk}">
                        <ul>
                            <li><a href="/website/productList?productTypeFirst=${item.pk}&page=1&limit=28" class="hover h${item.pk}">全部</a></li>
                            <#if list[item_index]?? && list[item_index]?size &gt;0>
                                <#list list[item_index] as lst>
                                    <li><a href="/website/productList?productTypeSecond=${lst.pk}&page=1&limit=28" class="H${lst.pk}">${lst.product_type_name}</a></li>
                                    <input type="hidden" id="secondtProductTypePk" value="${lst.pk}">
                                </#list>
                            </#if>
                        </ul>
                    </div>
                </#list>
            </#if>
        </div>
        <!--==产品==-->
        <div class="home_list">
            <!--内容-->
            <div class="home_list_n">
                <#if productList.list?? && productList.list?size &gt;0>
                    <#list productList.list as item>
                        <div class="home_list_nr">
                            <#assign imgPaths=item.product_avatar?split(";")>
                            <h1><a href="/website/productDetails?productPk=${item.pk}"><img src="//${imgPaths[0]}" width="275" height="275"></a></h1>
                            <#if item.is_new==1>
                                <h2><img src="/website/images/home_11.png"></h2>
                            <#elseif item.is_new==2>
                                <h2><img src="/website/images/home_12.png"></h2>
                            </#if>
                            <dl>
                                <dt><a href="/website/productDetails?productPk=${item.pk}">${item.product_name} ${item.product_title}</a></dt>
                                <#if item.product_sale??&&item.product_sale!="">
                                    <dd>${item.product_sale}<del>${item.product_price}</del></dd>
                                <#else>
                                    <dd>${item.product_price}</dd>
                                </#if>
                            </dl>
                        </div>
                    </#list>
                </#if>
            </div>
        </div>
        <!--翻页-->
        <div class="audio_cur_nr_fy">
            <ul class="pagination" id="pagination">
            </ul>
            <input type="hidden" id="PageCount" runat="server" />
            <input type="hidden" id="PageSize" runat="server" value="28" />
            <input type="hidden" id="countindex" runat="server" value="28" />
            <input type="hidden" id="visiblePages" runat="server" value="7" />
        </div>
    </div>
</div>

<!--==  版权  ==-->
<script type="text/javascript">
    function load_home() {
        document.getElementById("viewDiv").innerHTML = '';
    }
</script>
<object type="text/html" data="/website/copyright" width="100%" height="370px" style="margin-bottom: -5px;"></object>

<!--==  返回头部  ==-->
<script type="text/javascript" src="/website/js/backtop.js"></script>
</body>
<script>
    $(function () {
        $(".header-menu").find("ul").find("li").find("a").removeClass("hover");
        $(".header-menu").find("ul").find("li").eq(1).find("a").addClass("hover");
        showHover();//加载选中下标
        loadpage();//加载分页
    })

    function loadpage() {
        var currentUrl = window.location.href;
        $("#PageCount").val("${productList.total}");
        var myPageCount = parseInt($("#PageCount").val());
        var myPageSize = parseInt($("#PageSize").val());
        var countindex = myPageCount % myPageSize > 0 ? (myPageCount / myPageSize) + 1 : (myPageCount / myPageSize);
        $("#countindex").val(countindex);

        $.jqPaginator('#pagination', {
            totalPages: parseInt($("#countindex").val()),
            visiblePages: parseInt($("#visiblePages").val()),
            currentPage:${currentPage},
            first: '<li class="first"><a href="javascript:;">首页</a></li>',
            prev: '<li class="prev"><a href="javascript:;"><i class="arrow arrow2"></i>上一页</a></li>',
            next: '<li class="next"><a href="javascript:;">下一页<i class="arrow arrow3"></i></a></li>',
            last: '<li class="last"><a href="javascript:;">末页</a></li>',
            page: '<li class="page"><a href="javascript:;">{{page}}</a></li>',
            onPageChange: function (num, type) {
                //nowPage = num;//设置当前页码数
                if (type == "change") {
                    if(currentUrl.indexOf("productTypeFirst")!=-1){
                        var productTypeUrl = currentUrl.substring(currentUrl.indexOf("?")+1,currentUrl.indexOf("&"));
                        location.href="/website/productList?"+productTypeUrl+"&page="+num+"&limit=28";
                    }else if(currentUrl.indexOf("productTypeSecond")!=-1){
                        var productTypeUrl = currentUrl.substring(currentUrl.indexOf("?")+1,currentUrl.indexOf("&"));
                        location.href="/website/productList?"+productTypeUrl+"&page="+num+"&limit=28";
                    }else{
                        location.href="/website/productList?page="+num+"&limit=28";
                    }
                    /*$.ajax({
                        url : '/website/home/activitylist',
                        type : 'GET',
                        data : {
                            'page' : num,
                            'limit' : 16
                        },
                        dataType : 'JSON',
                        success : function(resp) {
                            apperndFunction(resp.data.list);
                            loadData(resp.data.total);
                        }
                    });*/
                }
            }
        });
    }
    function showHover(){
        var no3="${no3}"//商品栏目
        var firstPk="${firstPk}"//获取查询的一级分类pk
        var secondPk="${secondPk}"//获取查询发二级分类pk
        if(no3!=""){
            $(".prolis-screen").hide();
        }
        if(firstPk!=""){
            $("a").removeClass("hover");
            $(".h"+firstPk).addClass("hover");
        }
        if(secondPk!=""){
            $("a").removeClass("hover");
            $(".H"+secondPk).addClass("hover");
        }
    }
</script>
</html>